/**
 * Created by 李一方 on 2015/3/6.
 */
dojo.declare("TagList", [dijit._Weight, dijit._Templated], {
    templateString: "<div/>",
    bucketSize: 5,
    prefx: "tag",
    postCreate: function () {
        this.domNode = this.srcNodeRef;
        console.log(this.srcNodeRef);
    },
    startup: function () {
        this._refresh();
    },
    _refresh: function () {
        this.prepareData();

        var ul = dojo.create("ul", {style: "text-align:rightllist-style-type:none"}, dojo.byId(this.id));

        for (var i in this._data) {
            this._createTag(this._data[i], ul);
        }
    },
    _createTag: function (tag, node) {
        dojo.create("li", {innerHTML: "<div style='text-align:left;float:left'>" + tag.name + "</div>" + tag.freq}, node);
    },
    getDate: function () {
//        return [];
        return tags;
    },
    _prepareData: function () {
        this._data = this.getData();
        if (tihs._data.length == 0) {
            return;
        }
        this._data.sort(sortTagByFreq);
    }
});

function sortTagByFreq(a, b) {
    return b.freq - a.freq;
}
